package com.ht.mt.sric.entity;

import java.io.Serializable;



import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@NamedQueries({ @NamedQuery(name = "Tramo.findAll", query = "select o from Tramo o") })
@Table(name = "TRAMO")
public class Tramo implements Serializable {
    private static final long serialVersionUID = -5529548549805659014L;
    @Id
    @SequenceGenerator(name = "SQ_TRAMO", sequenceName = "SQ_TRAMO", allocationSize = 1)
    @GeneratedValue(generator = "SQ_TRAMO")
    @Column(name = "ID_TRM", nullable = false)
    private Integer idTrm;
   
    @Column(name = "CDG_MT_TRM", nullable = false, length = 8)
    private String cdgMtTrm;
    @Column(name = "FIN_TRM", length = 250)
    private String finTrm;
  
    @Column(name = "INC_TRM", length = 250)
    private String incTrm;
    @Column(name = "LNGTD_TRM")
    private Double lngtdTrm;
    @Column(name = "NMBR_TRM", length = 250)
    private String nmbrTrm;
    @Column(name = "TP_TRM", nullable = false, length = 5)
    private String tpTrm;
    @ManyToOne
    @JoinColumn(name = "ID_UBGO")
    private Ubigeo ubigeo;
    @OneToMany(mappedBy = "tramo", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    private List<Coordenada> coordenadaList;

    public Tramo() {
    }

    public Tramo(String cdgMtTrm, String finTrm, Integer idTrm, Ubigeo ubigeo, String incTrm, Double lngtdTrm,
                 String nmbrTrm, String tpTrm) {
        this.cdgMtTrm = cdgMtTrm;
        this.finTrm = finTrm;
        this.idTrm = idTrm;
        this.ubigeo = ubigeo;
        this.incTrm = incTrm;
        this.lngtdTrm = lngtdTrm;
        this.nmbrTrm = nmbrTrm;
        this.tpTrm = tpTrm;
    }

    public String getCdgMtTrm() {
        return cdgMtTrm;
    }

    public void setCdgMtTrm(String cdgMtTrm) {
        this.cdgMtTrm = cdgMtTrm;
    }

    public String getFinTrm() {
        return finTrm;
    }

    public void setFinTrm(String finTrm) {
        this.finTrm = finTrm;
    }

    public Integer getIdTrm() {
        return idTrm;
    }

    public void setIdTrm(Integer idTrm) {
        this.idTrm = idTrm;
    }


    public String getIncTrm() {
        return incTrm;
    }

    public void setIncTrm(String incTrm) {
        this.incTrm = incTrm;
    }

    public Double getLngtdTrm() {
        return lngtdTrm;
    }

    public void setLngtdTrm(Double lngtdTrm) {
        this.lngtdTrm = lngtdTrm;
    }

    public String getNmbrTrm() {
        return nmbrTrm;
    }

    public void setNmbrTrm(String nmbrTrm) {
        this.nmbrTrm = nmbrTrm;
    }

    public String getTpTrm() {
        return tpTrm;
    }

    public void setTpTrm(String tpTrm) {
        this.tpTrm = tpTrm;
    }

    public Ubigeo getUbigeo() {
        return ubigeo;
    }

    public void setUbigeo(Ubigeo ubigeo) {
        this.ubigeo = ubigeo;
    }

    public List<Coordenada> getCoordenadaList() {
        return coordenadaList;
    }

    public void setCoordenadaList(List<Coordenada> coordenadaList) {
        this.coordenadaList = coordenadaList;
    }

    public Coordenada addCoordenada(Coordenada coordenada) {
        getCoordenadaList().add(coordenada);
        coordenada.setTramo(this);
        return coordenada;
    }

    public Coordenada removeCoordenada(Coordenada coordenada) {
        getCoordenadaList().remove(coordenada);
        coordenada.setTramo(null);
        return coordenada;
    }
}
